<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<script type="text/javascript">
    $(document).ready(function(){
        var entityManagement = new EntityManagement();
        entityManagement.entityName = "节目";
        entityManagement.entityPath = "/program/program";
        entityManagement.entityTable = "programTable";
        entityManagement.sync = function (){

        }
        entityManagement.add = function (com, grid) {
            return top.qBox.iFLoad({title:'新增' + entityManagement.entityName, src:ctx + entityManagement.entityPath + "/input.action?fatherId=${id}", afterHide:entityManagement.refresh});
        }
        entityManagement.del = function(com, grid){
            var delArr = [];
            $('.trSelected').each(function(i,obj){
                delArr.push( obj.getAttribute("id"));
            })
            if(delArr.length == 0){
                top.Boxy.alert('请选择一条记录!', null, {title: "提示信息"});
                return false;
            }
            if(delArr.length > 1 ){
                top.Boxy.alert('最多选择一条记录!', null, {title: "提示信息"});
                return false;
            }
            jQuery.ajax({
                url:ctx + entityManagement.entityPath +  '/delete.action?id=' + delArr[0] + '&t=' + new Date().getTime(),
                type:"GET",
                success:function (data) {
                    var ret = eval('(' + data + ')');
                    var message = ret.message

                    top.Boxy.alert(message, null, {title:"提示信息"});

                    if (ret.code == 'A00000') {
                        entityManagement.refresh();
                    }
                }
            })
        }


        $("#"+entityManagement.entityTable).flexigrid({
            url : "/epg-web"+entityManagement.entityPath+'/list.action',
            dataType : 'json',
            height: "auto",
            title:"节目单信息",
            customTitle:false,
            params:[{"name":"fatherId",value:${id}}],
            colModel: [
                {display: 'UUID', name: 'id', width: 100, sortable: false, align: 'center', hide: false},
                {display: '奇谱ID', name: 'qipuId', width: 120, sortable: false, align: 'center'},
                {display: '开始时间', name: 'startPlayTime', width: 120, sortable: false, align: 'center'},
                {display: '结束时间', name: 'endPlayTime', width: 120, sortable: false, align: 'center'},
                {display: '节目名称', name: 'pname', width: 180, sortable: false, align: 'center'},
                {display: '节目类型', name: 'type', width: 100, sortable: false, align: 'center'},
                {display: '奇谈ID', name: 'qitanId', width: 100, sortable: false, align: 'center'},
                {display: '弹幕', name: 'popUps', width:80, sortable: false, align: 'center'},
                {display: '同步', name: 'sync', width:80, sortable: false, align: 'center'},

                {display: '免费状态', name: 'isMemberFree', width: 50, sortable: false, align: 'center'},
                {display: '会员限制', name: 'isMemberOnly', width: 50, sortable: false, align: 'center'},
                {display: '添加时间', name: 'addTime', width: 120, sortable: false, align: 'center'}

            ],
            useRp: false,
            usepager: false,
            buttons: [
                {"name": "新增", bclass: 'add', "onpress": entityManagement.add},
                {name : '修改', bclass : 'edit', onpress : entityManagement.edit},
                {"name": "删除", bclass: 'delete', "onpress": entityManagement.del}
               // {"name": "批量上线", "onpress": programTableExt.methodAction},
              //  {"name": "批量下线", "onpress": programTableExt.methodAction}
            ],
            height:400
        //    sortorder : "asc",
          //  rp : 24,
         //   rpOptions : [24, 40, 80, 100, 200]
        });
    })

</script>